<?php

class Journey {
    
    public static function start () {
        Config::$config = require ROOT_PATH . 'config' . DIRECTORY_SEPARATOR . 'config.php';
        self::_start();
    }
    
    private static function _start () {
        try{
            Dispatcher::dispatch();
        }catch (Dispatcher_StopException $ignored){
            
        }catch (Dispatcher_Exception $http_404){
            var_dump($http_404->getTrace());
            Dispatcher::forward('http404');
        }
        
        if (Context::get('tpl')) {
            
            $view = new View(Config::get('template','engine'));
            
            $view->display(Context::get('tpl'));
        }
    }
}
?>